import 'package:backend.purchases/infrastructure/dtos/yookassa_api/payments/pending_payment/yookassa_api_pending_payment_confirmation_info_dto.dart';
import 'package:backend.purchases/infrastructure/dtos/yookassa_api/payments/pending_payment/yookassa_api_pending_payment_redirect_confirmation_info_dto.dart';

class YookassaApiPendingPaymentConfirmationInfoDtoFactory {
  const YookassaApiPendingPaymentConfirmationInfoDtoFactory._internal();

  static const _instance = YookassaApiPendingPaymentConfirmationInfoDtoFactory._internal();

  factory YookassaApiPendingPaymentConfirmationInfoDtoFactory() {
    return _instance;
  }

  YookassaApiPendingPaymentConfirmationInfoDto fromJson(Map<String, dynamic> json) {
    final type = json[kYookassaApiPendingPaymentConfirmationInfoTypeKey] as String;

    if (type == kYookassaApiPendingPaymentRedirectConfirmationInfoTypeValue) {
      return YookassaApiPendingPaymentRedirectConfirmationInfoDto.fromJson(json);
    }

    throw UnimplementedError();
  }
}
